Skip to content

Add reasoningContent for model chat#402

Open
gongxh13 wants to merge 1 commit intoMacPaw:mainfrom
gongxh13:main
Open

Add reasoningContent for model chat#402
gongxh13 wants to merge 1 commit intoMacPaw:mainfrom
gongxh13:main

Conversation

@gongxh13
Copy link
Copy Markdown

@gongxh13 gongxh13 commented Jan 1, 2026

What

Add reasoningContent to the model invocation request body.

Why

Some models require the reasoningContent parameter to be passed in multiple calls within the same conversation round; otherwise, an error will occur. A typical example is the DeepSeek Reasoner model. See the official documentation: https://api-docs.deepseek.com/guides/thinking_mode#tool-calls

Affected Areas

Add a reasoningContent field to the message, defaulting to nil. It is passed to the model invocation only when explicitly provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for sending provider-specific assistant “reasoning content” back to chat-completions compatible APIs (e.g., DeepSeek Reasoner) by extending the encoded assistant message payload.

Changes:

  • Add reasoningContent: String? to ChatQuery.ChatCompletionMessageParam.AssistantMessageParam, encoded as reasoning_content.
  • Thread reasoningContent through the convenience ChatCompletionMessageParam.init?(role:content:...) when constructing .assistant messages.
  • Add a coding test to verify reasoning_content is emitted when provided.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Sources/OpenAI/Public/Models/ChatQuery.swift Introduces reasoningContent on assistant message params and encodes it as reasoning_content.
Tests/OpenAITests/ChatQueryCodingTests.swift Adds a JSON encoding test covering reasoning_content serialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants